<!DOCTYPE html>
<html lang="zh">
<head>
    <th:block th:include="include :: header('手动执行')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-editable-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row" style="margin-left:2px">
        <div class="col-sm-12 select-table table-striped" style="min-height:470px;">
            <table id="tableExecList" class="table table-bordered">
                <thead></thead>
                <tbody></tbody>
            </table>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-table-editable-js" />
    <script type="text/javascript">

        var prefix = ctx + "etl/query";
        $(function() {
            //var data = "{\"startDate\":\"2020-01-01\",\"endDate\":\"2020-01-01\",\"dimVOList\":[{\"idPubfld\":\"ID_DIM_DEPT_HIS\"},{\"idPubfld\":\"ID_DIM_DEPTNUR\"}],\"idIndexs\":[\"IDX_HIS_XRYRC\"],\"dateType\":\"D\"}"
            var data = "[[${data}]]";
            data = data.replaceAll("&quot;","\"");

            $.ajax({
                url: '/etl/query/commonDmQuery',
                type: 'post',
                dataType: 'json',
                contentType: 'application/json;charset=UTF-8',
                data:data,
                success: function (msg) {
                    var tbody = msg.data.tbody;
                    var thead = msg.data.thead;
                    var html="<tr>";
                    var theads =[],theadsKey=[];
                    $.each(thead,function(index,item) {
                        html+="<th>"+item+"</th>";
                        theads.push(item);
                        theadsKey.push(index);
                    });
                    $("#tableExecList thead").html(html+"</tr>");
                    html="";

                    for(var i=0;i<tbody.length;i++) {
                        html+="<tr>";
                        var trData = tbody[i];
                        for(var j=0;j<theadsKey.length;j++) {
                            html+="<td>"+(trData[theadsKey[j]]==undefined?0:trData[theadsKey[j]])+"</td>";
                        }
                        html+="</tr>";
                    }
                    $("#tableExecList tbody").html(html);
                }
            });
        });
        function searchData() {

            var startDate = $("#dateBegin").val();
            var endDate = $("#dateEnd").val();
            var idIndexs = $("#indexSelect").val();
            if(idIndexs.length==0) {
                $.modal.alertError("请先选择指标");
                return;
            }
            var dims = [];
            var rows = $("#"+table.options.id).bootstrapTable('getSelections');
            $.each(rows,function (index,item) {
                dims.push({"idPubfld":item.idPubfld,"filter":item.filter});
            });
        }
    </script>
</body>
</html>